package com.bvblogic.android.fragments;

import java.util.ArrayList;
import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

public class CustomFragmentStatePagerAdapter extends
		FragmentStatePagerAdapter {

	private List<AbstractFragment> fragmentsList;
	
	public CustomFragmentStatePagerAdapter(FragmentManager fm) {
		super(fm);
		fragmentsList = new ArrayList<AbstractFragment>();
	}

	@Override
	public Fragment getItem(int arg0) {
		// TODO Auto-generated method stub
		return fragmentsList.get(arg0);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return fragmentsList.size();
	}
	
	public void add(AbstractFragment fragment, String pageTitle) {
		fragment.setPageTitle(pageTitle);
		fragmentsList.add(fragment);
	}
	
	@Override
	public CharSequence getPageTitle(int position) {
		// TODO Auto-generated method stub
		return fragmentsList.get(position).getPageTitle();
	}

}
